package com.xlh.enums.course;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * 资源权限类型
 * <p>
 * Created by lx on 2019/4/15.
 */
@Getter
@AllArgsConstructor
public enum AuthorityOperatingTypeEnum {

    COURSE(1, "对课程进行设置权限"),
    CHAPTER(2, "对章节进行设置权限");

    private Integer code;

    private String message;

    public static AuthorityOperatingTypeEnum getByCode(int code) {
        for (AuthorityOperatingTypeEnum typeEnum : AuthorityOperatingTypeEnum.values()) {
            if (Objects.equals(typeEnum.getCode(), code)) {
                return typeEnum;
            }
        }
        return null;
    }

    public static String getMessageByCode(int code) {
        AuthorityOperatingTypeEnum typeEnum = getByCode(code);
        return typeEnum == null ? null : typeEnum.getMessage();
    }

}
